package com.huiquan.dyad.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.dyad.domain.DyadStd;
import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.vocab.domain.HiveSymptomDyadStd;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class DyadStdDao extends EnhancedBaseDao<DyadStd> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "DYAD_STD.";

	public DyadStdDao() {
		super(space);
	}

	@SuppressWarnings("unchecked")
	public List<DyadStd> retrieveUncheckedListByMultiDe() {
		return (List<DyadStd>) this.list(space + "RETRIEVE_UNCHECKED_LIST_BY_MULTI_DE", sqlMapClient);
	}

	public void initStdArray() {
		this.update(space + "INIT_STD_ARRAY", sqlMapClient);
	}

	@SuppressWarnings("unchecked")
	public List<DyadStd> retrieveWrongSingleDeList(String type) {
		Map<String, Object> param = new HashMap<>();
		param.put("type", type);
		return (List<DyadStd>) this.list(space + "RETRIEVE_WRONG_SINGLE_DE_LIST", param, sqlMapClient);
	}

	@SuppressWarnings("unchecked")
	public List<DyadStd> retrieveUncheckedMultiDeList(String type) {
		Map<String, Object> param = new HashMap<>();
		param.put("type", type);
		return (List<DyadStd>) this.list(space + "RETRIEVE_UNCHECKED_MULTI_DE_LIST", param, sqlMapClient);
	}

	public void initPOFlagByWrongPP() {
		this.update(space + "INIT_P_O_FLAG_BY_WRONG_P_P", sqlMapClient);
	}
	public void batchInsertSymptomDyadStd(List<HiveSymptomDyadStd> list) {
		int start = 0, end, size = list.size();
		List<HiveSymptomDyadStd> tempList;

		while (start < size) {
			if (start + 500 < size) {
				end = start + 500;
			} else {
				end = size;
			}
			tempList = list.subList(start, end);
			this.insert(space + "BATCH_INSERT_SYMPTOM_DYAD_STD", tempList, sqlMapClient);
			start += 500;
		}
	}

	public void initSymptomDyadStd() {
		this.update(space + "INIT_SYMPTOM_DYAD_STD", sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Map<String, String>> retrieveSymptomDyadStd() {
		return (List<Map<String, String>>) this.list(space + "RETRIEVE_SYMPTOM_DYAD_STD", sqlMapClient);
	}

	public void deleteAllSymptomDyadStd() {
		this.update(space + "DELETE_ALL_SYMPTOM_DYAD_STD", sqlMapClient);
		
	}
}
